home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 9
/
Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO
/
009a
/
snpd0493.zip
/
DRVALID.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-05
|
2KB
|
76 lines
.I 85 74
/*
** drvrdy()
**
** Checks whether a drive with removable media is ready.
**
** Arguments: 1 - target drive (0 = A;, 1 = B:, etc.)
**
** Returns: TRUE - drive is ready
** FALSE - drive is not ready
** ERROR - other read error
**
** Side effects: none
*/
LOGICAL drvrdy(int drive)
{
int status;
char buf[2048]; /* nice & roomy */
status = AbsDiskRead(drive, 1, 0, buf);
printf("AbsDiskRead(%d, 1, 0) returned 0x%X\n", drive, status);
if (0 == status)
return TRUE;
status &= 0xff;
if (2 == status)
return FALSE;
else return ERROR;
}
#ifdef TEST
#include <stdio.h>
#include <ctype.h>
int main(int argc, char *argv[])
{
int drive;
if (2 > argc)
{
puts("Usage: DRVALID drive[:]");
return EXIT_FAILURE;
}
drive = toupper(*argv[1]);
if (!isalpha(drive))
{
puts("Error: Invalid drive name");
return EXIT_FAILURE;
}
printf("Drive %c: is %svalid\n", drive,
drvalid(drive - 'A') ? "" : "not ");
if (2 < _osmajor)
{
union REGS regs;
regs.x.ax = 0x4408;
regs.h.bl = (unsigned char)(drive - '@');
intdos(®s, ®s);
printf("ioctl returned Cflag=%s\n",
regs.x.cflag ? "TRUE" : "FALSE");
printf("ioctl returned AX=0x%X\n", regs.x.ax);
printf("Drive %c is%s removable\n", drive,
regs.x.ax ? " not" : "");
if (0 == regs.x.ax)
{
printf("Drive %c is %sready\n", drive,
drvrdy(drive - 'A') ? "" : "not ");
}
}
return EXIT_SUCCESS;
}
#endif /* TEST */